<!DOCTYPE html>
<html>

<head>
  {include file="common/meta" /}
</head>

<body class="layui-anim layui-anim-up">
  <div class="x-body">
    <!-- 搜索 -->
    <!-- 搜索 -->
    <div class="layui-row">
      <form method="get" class="layui-form layui-col-md12 x-so">
        <input class="layui-input" placeholder="开始日" name="start" id="start" value="{$start}" />

        <input class="layui-input" placeholder="截止日" name="end" id="end" value="{$end}" />

        <input type="text" name="keywords" placeholder="请输入标题" autocomplete="off" value="{$keywords}"
          class="layui-input">

        <button class="layui-btn">
          <i class="layui-icon">&#xe615;</i>
        </button>
      </form>
    </div>

    <!-- 恢复 -->
    <xblock>
      <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量恢复</button>


      <span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
    </xblock>

    <!-- 分页列表 -->
    <table class="layui-table">
      <thead>
        <tr>
          <th>
            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i>
            </div>
          </th>
          <th>标题</th>
          <th>所属分类</th>
          <th>发布人</th>
          <th>访问次数</th>
          <th>帖子状态</th>
          <th>发布时间</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        {foreach $postlist as $item}
        <tr>
          <td>
            <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$item.id}'><i
                class="layui-icon">&#xe605;</i></div>
          </td>
          <th>{$item.title}</th>
          <th>{$item.cate.name}</th>
          <th>{$item.user.nickname}</th>
          <th>{$item.visit_text}</th>
          <th>{$item.accept ? '已采纳' : '未采纳'}</th>
          <th>{$item.createtime}</th>
          <td class="td-manage" style="">

            <a title="恢复" class="layui-btn layui-btn-sm layui-btn-danger" onclick="member_del(this,`{$item['id']}`)"
              href="javascript:;" style="width: 80px;">
              恢复帖子
            </a>

          </td>
        </tr>
        {/foreach}
      </tbody>
    </table>

    <!-- 分页 -->
    <div class="page">

      {$pagestr}

    </div>
  </div>
</body>

</html>
<script>
  layui.use('laydate', function () {
    var laydate = layui.laydate;

    //执行一个laydate实例
    laydate.render({
      elem: '#start' //指定元素
    });

    //执行一个laydate实例
    laydate.render({
      elem: '#end' //指定元素
    });
  });


  /*回收站-回复*/
  function member_del(obj, id) {
    layer.confirm('确认要恢复吗？', function (index) {
      //发异步恢复数据
      del(id)
    });
  }



  function delAll(argument) {

    var data = tableCheck.getData();

    layer.confirm('确认要恢复吗？' + data, function (index) {
      //将数组转换为字符串
      var ids = data.join(',')
      del(ids)
    });
  }

  function del(data) {

    //序列化 将对象转换为参数形式
    var params = {
      ids: data
    }

    params = $.param(params)

    $.ajax({
      url: `{:url('admin/post.post/replymsg')}`,
      type: 'post',
      data: params,
      dataType: 'json',
      success: function (success) {
        layer.msg(success.msg, { icon: 5, time: 1000 }, function () {
          location.reload()
        })
      }
    })
  }
</script>